package com.bq.gametrade.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bq.gametrade.R;
import com.bq.gametrade.bean.BindGameAccountDetails;

import java.util.ArrayList;

/**
 * @author Feel on 2016/11/29 11:05
 */

public class PlatformAccountAdapter extends BaseAdapter {
    private ArrayList<BindGameAccountDetails> items;
    private Context context;

    public PlatformAccountAdapter(Context context, ArrayList<BindGameAccountDetails> items) {
        this.context = context;
        this.items = items;
    }

    public void setData(ArrayList<BindGameAccountDetails> items){
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if(convertView == null){
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.listview_item_platformaccount,null);
            viewHolder.tvPlatformName = (TextView) convertView.findViewById(R.id.tv_platformName);
            viewHolder.tvPlatforAccount = (TextView) convertView.findViewById(R.id.tv_platformAccount);
            viewHolder.tvAccountMoney = (TextView) convertView.findViewById(R.id.tv_AccountMoney);


            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvPlatformName.setText(items.get(position).serverName);
        viewHolder.tvPlatforAccount.setText(items.get(position).account);
        viewHolder.tvAccountMoney.setText(items.get(position).account);



       return convertView;
    }

    class ViewHolder{
        TextView tvPlatformName;
        TextView tvPlatforAccount;
        TextView tvAccountMoney;



    }

}
